/*
 * Copyright 2010. 
 * 
 * This document may not be reproduced, distributed or used 
 * in any manner whatsoever without the expressed written 
 * permission of xrkol Corp. 
 * 
 * $Rev: Rev $
 * $Author: Author $
 * $LastChangedDate: LastChangedDate $
 *
 */

package com.xrkol.sharelib.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xrkol.sharelib.dao.TopicDao;
import com.xrkol.sharelib.entity.Clazz;
import com.xrkol.sharelib.entity.Topic;
import com.xrkol.sharelib.util.CommonUtils;

/**
 * @author peng.xia
 *
 */
@Repository
public class TopicDaoImpl extends BaseDaoImpl<Topic, String> implements TopicDao{

    @Override
    public List<Topic> getTopics(Clazz clazz, Integer page) {
        String queryString="from Topic t where t.classId = ? order by createAt desc";
        return executeQueryWithoutPaging(queryString,clazz.getId());
    }

    @Override
    public List<Topic> getTopics(List<String> classIds, Integer page) {
        String queryString="from Topic t where t.classId in " + CommonUtils.transListForSqlIn(classIds.size());
        return executeQueryWithPagination(queryString, " order by t.createAt desc", page, classIds.toArray());
    }

}
